package com.bluesky.example.myaop.interceptors;

import java.lang.reflect.Method;
import java.util.Date;
import java.util.logging.Logger;

import com.bluesky.example.myaop.MethodInterceptor;

public class PerformanceInterceptor implements MethodInterceptor {
	private Logger logger = Logger.getLogger(this.getClass().getName());

	private Date start;

	@Override
	public void Before(Object target, Method method, Object[] args) {

		logger.info("PerformanceInterceptor method before..." + method.getName());
		start = new Date();

	}

	@Override
	public void After(Object target, Method method, Object[] args) {

		Date end = new Date();

		long milliSec = end.getTime() - start.getTime();

		logger.info("PerformanceInterceptor method after...elapsed:" + milliSec + " milliseconds");
	}
}
